package com.ruoyi.project.blog.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.blog.domain.BNavigation;
import com.ruoyi.project.blog.service.IBNavigationService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 网站导航Controller
 * 
 * @author ruoyi
 * @date 2023-10-10
 */
@RestController
@RequestMapping("/webManage/navigation")
public class BNavigationController extends BaseController
{
    @Autowired
    private IBNavigationService bNavigationService;

    /**
     * 查询网站导航列表
     */
    @GetMapping("/list")
    public TableDataInfo list(BNavigation bNavigation)
    {
        startPage();
        List<BNavigation> list = bNavigationService.selectBNavigationList(bNavigation);
        return getDataTable(list);
    }

    /**
     * 导出网站导航列表
     */
    @Log(title = "网址管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BNavigation bNavigation)
    {
        List<BNavigation> list = bNavigationService.selectBNavigationList(bNavigation);
        ExcelUtil<BNavigation> util = new ExcelUtil<BNavigation>(BNavigation.class);
        util.exportExcel(response, list, "网站导航数据");
    }

    /**
     * 获取网站导航详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(bNavigationService.selectBNavigationById(id));
    }

    /**
     * 新增网站导航
     */
    @Log(title = "网址管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BNavigation bNavigation)
    {
        return toAjax(bNavigationService.insertBNavigation(bNavigation));
    }

    /**
     * 修改网站导航
     */
    @Log(title = "网址管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BNavigation bNavigation)
    {
        return toAjax(bNavigationService.updateBNavigation(bNavigation));
    }

    /**
     * 删除网站导航
     */
    @Log(title = "网址管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bNavigationService.deleteBNavigationByIds(ids));
    }

    @GetMapping("/navigationRole/{siteClassId}")
    public AjaxResult navigationRole(@PathVariable("userId") Long userId)
    {
        AjaxResult ajax = AjaxResult.success();
        return ajax;
    }
}
